package com.ruoyi.business.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.business.domain.CzEquipmentTrajectory;
import com.ruoyi.business.service.ICzEquipmentTrajectoryService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 设备任务轨迹Controller
 * 
 * @author ruoyi
 * @date 2022-01-09
 */
@Api(tags = "设备任务轨迹")
@RestController
@RequestMapping("/business/equipment_trajectory")
public class CzEquipmentTrajectoryController extends BaseController
{
    @Autowired
    private ICzEquipmentTrajectoryService czEquipmentTrajectoryService;

    /**
     * 查询设备任务轨迹列表
     */
    @ApiOperation(value = "查询设备任务轨迹列表")
    @PreAuthorize("@ss.hasPermi('business:equipment_trajectory:list')")
    @GetMapping("/list")
    public TableDataInfo list(CzEquipmentTrajectory czEquipmentTrajectory)
    {
        startPage();
        List<CzEquipmentTrajectory> list = czEquipmentTrajectoryService.selectCzEquipmentTrajectoryList(czEquipmentTrajectory);
        return getDataTable(list);
    }

    /**
     * 导出设备任务轨迹列表
     */
    @ApiOperation(value = "导出设备任务轨迹列表")
    @PreAuthorize("@ss.hasPermi('business:equipment_trajectory:export')")
    @Log(title = "设备任务轨迹", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CzEquipmentTrajectory czEquipmentTrajectory)
    {
        List<CzEquipmentTrajectory> list = czEquipmentTrajectoryService.selectCzEquipmentTrajectoryList(czEquipmentTrajectory);
        ExcelUtil<CzEquipmentTrajectory> util = new ExcelUtil<CzEquipmentTrajectory>(CzEquipmentTrajectory.class);
        util.exportExcel(response, list, "设备任务轨迹数据");
    }

    /**
     * 获取设备任务轨迹详细信息
     */
    @ApiOperation(value = "获取设备任务轨迹详细信息")
    @PreAuthorize("@ss.hasPermi('business:equipment_trajectory:query')")
    @GetMapping(value = "/{trajectoryId}")
    public AjaxResult getInfo(@PathVariable("trajectoryId") String trajectoryId)
    {
        return AjaxResult.success(czEquipmentTrajectoryService.selectCzEquipmentTrajectoryByTrajectoryId(trajectoryId));
    }

    /**
     * 新增设备任务轨迹
     */
    @ApiOperation(value = "新增设备任务轨迹")
    @PreAuthorize("@ss.hasPermi('business:equipment_trajectory:add')")
    @Log(title = "设备任务轨迹", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CzEquipmentTrajectory czEquipmentTrajectory)
    {
        return toAjax(czEquipmentTrajectoryService.insertCzEquipmentTrajectory(czEquipmentTrajectory));
    }

    /**
     * 修改设备任务轨迹
     */
    @ApiOperation(value = "修改设备任务轨迹")
    @PreAuthorize("@ss.hasPermi('business:equipment_trajectory:edit')")
    @Log(title = "设备任务轨迹", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CzEquipmentTrajectory czEquipmentTrajectory)
    {
        return toAjax(czEquipmentTrajectoryService.updateCzEquipmentTrajectory(czEquipmentTrajectory));
    }

    /**
     * 删除设备任务轨迹
     */
    @ApiOperation(value = "删除设备任务轨迹")
    @PreAuthorize("@ss.hasPermi('business:equipment_trajectory:remove')")
    @Log(title = "设备任务轨迹", businessType = BusinessType.DELETE)
	@DeleteMapping("/{trajectoryIds}")
    public AjaxResult remove(@PathVariable String[] trajectoryIds)
    {
        return toAjax(czEquipmentTrajectoryService.deleteCzEquipmentTrajectoryByTrajectoryIds(trajectoryIds));
    }
}
